﻿<UserControl
  x:Name="This"
  x:Class="SqlMiM.Views.DocumentsView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:a="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
  MinWidth="200" MinHeight="200">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary   Source="/SqlMiM.Common;component/Resources/EditorTabControl.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>

        <TabControl x:Name="DocumentTabControl"
                      Style="{DynamicResource EditorTabControl}"
                      ItemsSource="{Binding ElementName=This, Path=CurrentPlugins}"
                      SelectedItem="{Binding ElementName=This, Path=ActivePlugin, Mode=TwoWay}"
                      >
            <TabControl.Resources>
                <Style x:Key="{x:Type ToolTip}" TargetType="{x:Type ToolTip}">
                    <Setter Property="OverridesDefaultStyle" Value="true"/>
                    <Setter Property="HasDropShadow" Value="False"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ToolTip}">
                                <ContentPresenter/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.Resources>

            
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="-10" Background="#0f00" ToolTipService.InitialShowDelay="1000">
                        <Grid.ToolTip>
                            <a:SystemDropShadowChrome SnapsToDevicePixels="True" CornerRadius="4" Margin="0,0,5,5" HorizontalAlignment="Center" VerticalAlignment="Center">
                                <Grid >
                                    <Border CornerRadius="4" BorderBrush="#8FFF"  BorderThickness="0,1,0,0">
                                        <Border.Background>
                                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                                <GradientStop Offset="0.0" Color="#C0606060" />
                                                <GradientStop Offset="1.0" Color="#C0303030" />
                                            </LinearGradientBrush>
                                        </Border.Background>
                                    </Border>
                                    <Border CornerRadius="4" Width="160" Height="110" Margin="8" >
                                        <!--<Border.Background>
                                            <ImageBrush ImageSource="{Binding PreviewImage}" Stretch="UniformToFill" />
                                        </Border.Background>-->
                                    </Border>
                                </Grid>
                            </a:SystemDropShadowChrome>
                        </Grid.ToolTip>
                        <TextBlock Margin="4">
                            <Image Source="{Binding Icon}" Width="12" />                            
                            <TextBlock Text="{Binding Name}" />
                            <TextBlock x:Name="Star" Text="*" Margin="-4,0,0,0" Visibility="Visible" />
                        </TextBlock>
                    </Grid>
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding NeedsSave}" Value="False">
                            <Setter TargetName="Star" Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </TabControl.ItemTemplate>

            <TabControl.ContentTemplate>
                <DataTemplate>
                    <UserControl Content="{Binding Display}" ></UserControl>
                </DataTemplate>
            </TabControl.ContentTemplate>

        </TabControl>
    </Grid>

</UserControl>
